package com.onlinescxhz.demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.onlinescxhz.demo.common.Result;
import com.onlinescxhz.demo.pojo.Customer;
import com.onlinescxhz.demo.service.CustomerServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin
@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Resource
    private CustomerServiceImpl customerService;

    @PostMapping("/login")
    public Result login(@RequestBody Customer customer){
           System.out.println(customer);
        QueryWrapper<Customer> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("account",customer.getAccount());
        queryWrapper.eq("password",customer.getPassword());
        Customer customernew= null;
        customernew=customerService.getOne(queryWrapper);
        System.out.println(customernew);
        if(customernew==null){
            return Result.error();
        }else {
            return Result.seccess(customernew);
        }
    }
}
